package org.ilead.iserve.service.impl;

import java.util.List;

import org.ilead.iserve.dao.IHomePageDAO;
import org.ilead.iserve.model.HomePage;
import org.ilead.iserve.service.IHomePageService;

public class HomePageService implements IHomePageService {
	
	private IHomePageDAO homePageDAO;

	public void setHomePageDAO(IHomePageDAO homePageDAO) {
		this.homePageDAO = homePageDAO;
	}

	@Override
	public void save(HomePage homePage) {
		homePageDAO.save(homePage);
	}

	@Override
	public HomePage findById(int id) {
		return homePageDAO.findById(id);
	}

	@Override
	public HomePage findByUrl(String url) {
		List<HomePage> pageList = homePageDAO.findByUrl(url);
		return pageList != null && pageList.size() > 0 ? pageList.get(0) : null;
	}

	@Override
	public HomePage findByUserId(int userId) {
		List<HomePage> pageList = homePageDAO.findByUserId(userId);
		return pageList != null && pageList.size() > 0 ? pageList.get(0) : null;
	}

	

}
